//
//  EWTabBarController.m
//  haveSomethingToEat
//
//  Created by 陈宁权 on 2017/4/8.
//  Copyright © 2017年 陈 宁权. All rights reserved.
//

#import "EWTabBarController.h"
#import "EWHomeViewController.h"
#import "EWReservationViewController.h"
#import "EWMineViewController.h"
#import "EWOrderViewController.h"
#import "EWFriendViewController.h"
#import "EWBaseNavViewController.h"

@interface EWTabBarController ()
@property (nonatomic,strong) NSMutableArray *ControllerArr;
@end

@implementation EWTabBarController

- (NSMutableArray *)ControllerArr
{
    if (!_ControllerArr) {
        _ControllerArr = [NSMutableArray array];
    }
    return _ControllerArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIView *backView = [[UIView alloc] initWithFrame:self.view.frame];
    backView.backgroundColor = [UIColor whiteColor];
    [self.tabBar insertSubview:backView atIndex:0];
    
    //设置tabbar全局背景颜色
    self.view.backgroundColor = [UIColor whiteColor];
    
    //设置tabbar不透明
    self.tabBar.opaque = YES;
    self.tabBar.tintColor = BASE_COLOR;
    
    
    [self setupChildViewConrtollers];
}

- (void)setupChildViewConrtollers
{
    //首页
    EWReservationViewController *homeVC = [[EWReservationViewController alloc] init];
    [homeVC.tabBarItem setTitle:@"首页"];
    [homeVC.tabBarItem setImage:[UIImage imageNamed:@"btn_home_normal"]];
    EWBaseNavViewController *homeNAV = [[EWBaseNavViewController alloc] initWithRootViewController:homeVC];
    [self.ControllerArr addObject:homeNAV];
    
    //订单
    EWOrderViewController *orderVC = [[EWOrderViewController alloc] init];
    [orderVC.tabBarItem setTitle:@"订单"];
    [orderVC.tabBarItem setImage:[UIImage imageNamed:@"btn_order_normal"]];
    EWBaseNavViewController *orderNAV = [[EWBaseNavViewController alloc] initWithRootViewController:orderVC];
    [self.ControllerArr addObject:orderNAV];
    
    //朋友
    EWFriendViewController *friendVC = [[EWFriendViewController alloc] init];
    [friendVC.tabBarItem setTitle:@"朋友"];
    [friendVC.tabBarItem setImage:[UIImage imageNamed:@"btn_friend_normal"]];
    EWBaseNavViewController *friendNAV = [[EWBaseNavViewController alloc] initWithRootViewController:friendVC];
    [self.ControllerArr addObject:friendNAV];
    
    //我的
    EWMineViewController *mineVC = [[EWMineViewController alloc] init];
    [mineVC.tabBarItem setTitle:@"我的"];
    [mineVC.tabBarItem setImage:[UIImage imageNamed:@"btn_mine_normal"]];
    EWBaseNavViewController *mineNAV = [[EWBaseNavViewController alloc] initWithRootViewController:mineVC];
    [self.ControllerArr addObject:mineNAV];
    
    [self setViewControllers:self.ControllerArr];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
